#ifndef STREAM_H
#define STREAM_H

#include <stdio.h>
#include "../Basic/String.h"

namespace Lyt
{
	namespace IO
	{
		enum SeekOrigin
		{
			seekBegin,
			seekCurrent,
			seekEnd
		};

		enum FileMode
		{
			modeRead,
			modeWrite,
			modeAppend,
			modeReadWrite
		};

		class IStream
		{
		public:
			virtual ~IStream();
			virtual bool IsAvailable()const=0;
			virtual bool IsEnd()const=0;
			virtual bool CanClose()const=0;
			virtual bool CanRead()const=0;
			virtual bool CanWrite()const=0;
			virtual bool CanSeek()const=0;
			virtual bool CanPeek()const=0;
			virtual void Close()=0;
			virtual int Seek(const int Offset, SeekOrigin Origin)=0;
			virtual int Peek(void* Buffer, const int ByteCount)=0;
			virtual int Read(void* Buffer, const int ByteCount)=0;
			virtual void Write(const void* Buffer, const int ByteCount)=0;
			virtual int GetLength()const=0;
			virtual int GetPosition()const=0;
		};

		class FileStream : public IStream
		{
		protected:
			FILE* Stream;
			FileMode Mode;

		public:
			WString Name;

			FileStream();
			FileStream(const WString FileName, const FileMode ObjectMode);
			virtual ~FileStream();

			virtual bool IsAvailable()const;
			virtual bool IsEnd()const;
			virtual bool CanClose()const;
			virtual bool CanRead()const;
			virtual bool CanWrite()const;
			virtual bool CanSeek()const;
			virtual bool CanPeek()const;
			virtual void Close();
			virtual int Seek(const int Offset, SeekOrigin Origin);
			virtual int Peek(void* Buffer, const int ByteCount);
			virtual int Read(void* Buffer, const int ByteCount);
			virtual void Write(const void* Buffer, const int ByteCount);
			virtual int GetLength()const;
			virtual int GetPosition()const;
		};
	}
}

#endif